<!DOCTYPE html>
<html>
<head>
	{include file="common_header" /}
	{include file="common_top" /}
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-header">添加余额</div>
      <div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" action="" lay-filter="component-form-group">

          
          <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
              <input type="text" name="phone" id="phone"   placeholder="手机号" class="layui-input">
            </div>
          </div>
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">充值金额</label>
            <div class="layui-input-block">
              <input type="text" name="money" id="money"   placeholder="充值金额" class="layui-input">
            </div>
          </div>

		  <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
              <input type="text" name="content" id="content"   placeholder="备注" class="layui-input">
            </div>
          </div>
	      
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <div class="layui-btn sub">立即提交</div>
                <button type="reset" class="layui-btn layui-btn-primary ">重置</button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
{include file="common_footer" /} 
<script>
$(".sub").click(function(){
	//if(!$(".btn").hasClass("sub")){return false;}
	var phone        = $("#phone").val();
	var money        = $("#money").val();
	var content        = $("#content").val();

	if(phone == ""){
		show_error("手机号不能为空");
		return false
	}
	
	if(money == ""){
		show_error("充值金额不能为空");
		return false
	}

	
	$.ajax({
		type:"POST",
		url:"{:url('recharge/add')}",
		dataType:"json",
		data:{
			phone:phone,
			money:money,
			content:content,
		},
		success:function(res){
			if(res.status == "success"){
				show_toast_callurl(res.data,"{:url('recharge/index')}","success");
			}else{
				show_error(res.data);
			}
		},
		error:function(jqXHR){
			console.log("Error: "+jqXHR.status);
		},
	});
	
});
</script>
</body>
</html>
